﻿using Microsoft.Xaml.Interactivity;
using Windows.UI.Xaml;

namespace CalendarWindowsApp.Behaviors
{
    public abstract class BehaviorBase : DependencyObject, IBehavior
    {
        private DependencyObject associatedObject;

        public DependencyObject AssociatedObject
        {
            get
            {
                return associatedObject;
            }
        }

        public void Attach(DependencyObject associatedObject)
        {
            this.associatedObject = associatedObject;
            OnAttached();
        }

        protected virtual void OnAttached()
        {
        }

        public void Detach()
        {
            OnDetaching();
            associatedObject = null;
        }

        protected virtual void OnDetaching()
        {
        }
    }
}